{template header}
<div class="console-title">
    <a href="{U:('c=company&a=index')}" class="button float-right">返回列表</a>
    <h2>添加企业信息</h2>
</div>
<div class="content-div">
    <form method="post" id="companyForm">
        <input type="hidden" name="formsubmit" value="yes">
        <input type="hidden" name="formhash" value="{FORMHASH}">
        <table cellpadding="0" cellspacing="0" width="100%" class="formtable">
            <tbody>
            <tr>
                <td width="80">企业名称</td>
                <td width="320"><input name="company[company_name]" id="company_name" title="" type="text" class="input-text" value="{$company[company_name]}"></td>
                <td class="tips">企业名称，至少两个字，不能含有特殊字符和符号</td>
            </tr>
            <tr>
                <td>所属分类</td>
                <td>
                    <select class="select" title="" name="company[catid]">
                        {loop $catloglist[0] $cat1}
                        <option value="{$cat1[catid]}"{if $cat1[catid]==$company[catid]} selected{/if}>{$cat1[name]}</option>
                            {loop $catloglist[$cat1[catid]] $cat2}
                            <option value="{$cat2[catid]}"{if $cat2[catid]==$company[catid]} selected{/if}>|--{$cat2[name]}</option>
                                {loop $catloglist[$cat2[catid]] $cat3}
                                <option value="{$cat3[catid]}"{if $cat3[catid]==$company[catid]} selected{/if}>|--|--{$cat3[name]}</option>
                                {/loop}
                            {/loop}
                        {/loop}
                    </select>
                </td>
                <td class="tips"></td>
            </tr>
            <tr>
                <td>企业LOGO</td>
                <td>
                    <div class="bg-cover" id="pickLogo" style="width: 100px; height: 100px; background-color: #f5f5f5; background-image: url({img $company[company_logo]});"></div>
                    <input type="hidden" name="company[company_logo]" id="company_logo" value="{$company[company_logo]}">
                </td>
                <td class="tips">图片格式为jpg，jpeg，png，gif，大小不要超过2MB</td>
            </tr>
            <tr>
                <td>门头照片</td>
                <td>
                    <div class="bg-cover" id="pickImage" style="width: 100px; height: 100px; background-color: #f5f5f5;background-image: url({img $company[company_image]});"></div>
                    <input type="hidden" name="company[company_image]" id="company_image" value="{$company[company_image]}">
                </td>
                <td class="tips">图片格式为jpg，jpeg，png，gif，大小不要超过2MB</td>
            </tr>
            <tr>
                <td>营业执照号码</td>
                <td><input name="company[company_license_no]" title="" type="text" class="input-text" value="{$company[company_license_no]}"></td>
                <td class="tips">请填写营业执照号码</td>
            </tr>
            <tr>
                <td>营业执照照片</td>
                <td>
                    <div class="bg-cover" id="pickLicensePic" style="width: 100px; height: 100px; background-color: #f5f5f5;background-image: url({img $company[company_license_pic]});"></div>
                    <input name="company[company_license_pic]" type="hidden" id="company_license_pic" value="{$company[company_license_pic]}">
                </td>
                <td class="tips">图片格式为jpg，jpeg，png，gif，大小不要超过2MB</td>
            </tr>
            <tr>
                <td>所在地区</td>
                <td colspan="2">
                    <select name="company[province]" class="select" title="" id="province" style="width: auto;"></select>
                    <select name="company[city]" class="select" title="" id="city" style="width: auto;"></select>
                    <select name="company[county]" class="select" title="" id="county" style="width: auto;"></select>
                </td>
            </tr>
            <tr>
                <td>街道地址</td>
                <td><input name="company[street]" title="" type="text" class="input-text" value="{$company[street]}"></td>
                <td class="tips">企业所在地街道地址</td>
            </tr>
            <tr>
                <td>联系人</td>
                <td><input name="company[contact]" title="" type="text" class="input-text" value="{$company[contact]}"></td>
                <td class="tips">企业联系人</td>
            </tr>
            <tr>
                <td>联系电话</td>
                <td><input name="company[tel]" title="" type="text" class="input-text" value="{$company[tel]}"></td>
                <td class="tips">企业联系电话</td>
            </tr>
            <tr>
                <td>企业介绍</td>
                <td colspan="2">{template editor}</td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <td></td>
                <td colspan="2">
                    <button type="submit" class="button button-long">提交</button>
                </td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $("#pickLogo").on('click', function () {
            DSXUI.showImagePicker(function (data) {
                $("#pickLogo").css({'background-image':'url('+data.imageurl+')'});
                $("#company_logo").val(data.image);
            });
        });

        $("#pickImage").on('click', function () {
            DSXUI.showImagePicker(function (data) {
                $("#pickImage").css({'background-image':'url('+data.imageurl+')'});
                $("#company_image").val(data.image);
            });
        });

        $("#pickLicensePic").on('click', function () {
            DSXUI.showImagePicker(function (data) {
                $("#pickLicensePic").css({'background-image':'url('+data.imageurl+')'});
                $("#company_license_pic").val(data.image);
            });
        });

        var selector = new DistrictSelector({
            province:'{$company[province]}',
            city:'{$company[city]}',
            county:'{$company[county]}',
        });

        $("#companyForm").on('submit', function () {
            var company_name = $.trim($("#company_name").val());
            if (!company_name) {
                DSXUI.error('请填写企业名称');
                return false;
            }
        });
    });
</script>
{template footer}